using System.Data;
using System.Windows.Forms;
using ctsu.Admin.BusLogic.CoreLab;
using Syncfusion.Windows.Forms.Grid;
using ctsu.BaseForms;

namespace ctsu.Admin.BusLogic
{
	class BLFormGridOffUnitActivitiesImpl : BLCoreLabFormGridBaseImpl
	{
		public BLFormGridOffUnitActivitiesImpl(FormGridMeta formGridMeta, GridControl grid, FormInfoBase formInfo, Form form)
			: base(formGridMeta, grid, formInfo, form)
		{

		}

		public override void AddRow(object obj, int row)
		{
			OffUnitActivity act = (OffUnitActivity)obj;
			DataRow dr = _data.NewRow();
			this._data.Rows.Add(dr);

			int rows = ++this._grid.RowCount;
			this._grid[rows, 0].Tag = dr;

			this._grid[rows, 2].CellValue = act.ProtocolID;
			AssignChangeToDataRow(rows, 2);
			this._grid[rows, 3].CellValue = act.ActivityID;
			AssignChangeToDataRow(rows, 3);
			this._grid[rows, 4].CellValue = act.Duration;
			AssignChangeToDataRow(rows, 4);
			this._grid[rows, 5].CellValue = act.Patients;
			AssignChangeToDataRow(rows, 5);

			this._grid.ScrollCellInView(this._grid.RowCount, 0);
			this._btnRemoveBatch.Enabled = true;
			this._btnSave.Enabled = true;
		}

		public override void RemoveRow(int row)
		{
			DataRow dr = (DataRow)this._grid[row, 0].Tag;
			dr.Delete();
			this._grid.Model.Rows.RemoveRange(row, row);
		}
	}
}
